/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.apiGenerator.dataType.entityInterface.propertyInfo;

import com.inspur.edp.bef.bizentity.GspBizEntityElement;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.property.ClassPropertyGenerator;
import com.inspur.edp.cef.designtime.api.IGspCommonField;
import com.inspur.edp.cef.designtime.api.entity.GspCommonDataType;
import com.inspur.edp.cef.generator.apiGenerator.dataType.entityInterface.DataTypeInterfaceGeneratorContext;
import com.inspur.edp.cef.generator.entityGenerator.base.DataTypeGeneratorContext;
import org.eclipse.jdt.core.dom.*;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class PropInfoIsDefaultNullGenerator extends ClassPropertyGenerator {
    DataTypeInterfaceGeneratorContext parentContext;
    GspBizEntityElement field;
    public PropInfoIsDefaultNullGenerator(DataTypeInterfaceGeneratorContext parentContext,GspBizEntityElement field){
        this.parentContext=parentContext;
        this.field=field;
    }

    @Override
    protected boolean isGetterOverride() {
        return true;
    }
    @Override
    protected ArrayList<Modifier.ModifierKeyword> getGetterAccessModifier() {
        return new java.util.ArrayList<Modifier.ModifierKeyword>(
                java.util.Arrays.asList(
                        new Modifier.ModifierKeyword[] {
                                Modifier.ModifierKeyword.PUBLIC_KEYWORD
                        }));
    }

    @Override
    protected ArrayList<Modifier.ModifierKeyword> getSetterAccessModifier() {
        return null;
    }

    @Override
    protected TypeInfo getPropertyType() {
        return new TypeInfo(boolean.class.getName());
    }

    @Override
    protected String getPropertyName() {
        return "IsDefaultNull";
    }
    @Override
    protected org.eclipse.jdt.core.dom.Block buildGetMethodBody() {
        ReturnStatement returnStatement = ast.newReturnStatement();
        if(field.getIsDefaultNull()){
            BooleanLiteral  booleanLiteral = ast.newBooleanLiteral(true);
            returnStatement.setExpression(booleanLiteral);
        }else {
            BooleanLiteral  booleanLiteral1 = ast.newBooleanLiteral(false);
            returnStatement.setExpression(booleanLiteral1);
        }
        Block result = ast.newBlock();
        result.statements().add(returnStatement);
        return result;
    }
    @Override
    protected boolean hasSetMethod() {
        return false;
    }
}
